﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="LatePayments.aspx.cs" Inherits="Operator_LatePayments" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <br />
<asp:HyperLink ID="OperatorLink" runat="server" NavigateUrl="~/Operator/OperatorPanel.aspx">Панель оператора</asp:HyperLink> &nbsp;→ 
    <asp:Label ID="ContractLabel" runat="server" Text="Просроченные платежи" Font-Bold="true"></asp:Label><br/>
<br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSourceLatePayments" 
        onselectedindexchanged="GridView1_SelectedIndexChanged" 
        DataKeyNames="ContractId" ondatabinding="GridView1_DataBinding" 
        onrowdatabound="GridView1_RowDataBound">
        <Columns>
            <asp:BoundField DataField="Предприятие" HeaderText="Предприятие" 
                SortExpression="Предприятие" />
            <asp:BoundField DataField="Кредит" HeaderText="Кредит" 
                SortExpression="Кредит" />
            <asp:BoundField DataField="Срок" HeaderText="Срок" SortExpression="Срок" />
            <asp:BoundField DataField="Сумма" HeaderText="Сумма" SortExpression="Сумма" />
            <asp:BoundField DataField="Валюта" HeaderText="Валюта" 
                SortExpression="Валюта" />
            <asp:BoundField DataField="Проценты" HeaderText="Проценты" 
                SortExpression="Проценты" />
            <asp:BoundField DataField="Дата получения" HeaderText="Дата получения" 
                SortExpression="Дата получения" />
            <asp:BoundField HeaderText="Просроченная сумма" 
                ReadOnly="True" SortExpression="Просроченная сумма" />
                 <asp:BoundField DataField="Последнее уведомление" 
                HeaderText="Последнее уведомление" SortExpression="Последнее уведомление" />
            <asp:CommandField SelectText="Уведомить" ShowSelectButton="True" />
        </Columns>
        <EmptyDataTemplate>
            Просроченных платежей нет.
        </EmptyDataTemplate>
    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSourceLatePayments" runat="server" 
        ConnectionString="<%$ ConnectionStrings:BankDBConnectionString %>" 
        
        
        SelectCommand="SELECT Company.CompanyName AS Предприятие, Credit.Name AS Кредит, Contract.TermLength AS Срок, Contract.Amount AS Сумма, Currency.Name AS Валюта, CreditCurrency.Percentage AS Проценты, Contract.CreationDate AS [Дата получения], Contract.ContractId, Contract.LastNotificationLatePaymentDate AS [Последнее уведомление] FROM Contract INNER JOIN Credit ON Contract.CreditId = Credit.CreditID INNER JOIN CreditCurrency ON Credit.CreditID = CreditCurrency.CreditId INNER JOIN Currency ON Contract.CurrencyId = Currency.CurrencyID AND CreditCurrency.CurrencyId = Currency.CurrencyID INNER JOIN Company ON Contract.CompanyId = Company.CompanyId INNER JOIN UserProfile ON Company.CompanyId = UserProfile.CompanyId GROUP BY Company.CompanyName, Contract.StatusId, Credit.Name, Contract.Amount, Currency.Name, Contract.TermLength, Contract.CreationDate, CreditCurrency.Percentage, Contract.ContractId, Contract.LastNotificationLatePaymentDate, UserProfile.OperatotId HAVING (Contract.StatusId = 1) AND (UserProfile.OperatotId = @OperatorId)"
        
        >
        
        <SelectParameters>
            <asp:Parameter Name="OperatorId" />
        </SelectParameters>
    </asp:SqlDataSource>

</asp:Content>

